#!/bin/bash

# 桌面时钟安装脚本
# Desktop Timer Installation Script

echo "==================================="
echo "桌面时钟 - 安装程序"
echo "Desktop Timer - Installer"
echo "==================================="

# 设置安装目录
INSTALL_DIR="$HOME/.local/share/desktop-timer"
DESKTOP_FILE="$HOME/.local/share/applications/desktop-timer.desktop"

# 创建安装目录
echo "创建安装目录..."
mkdir -p "$INSTALL_DIR"
mkdir -p "$HOME/.local/share/applications"

# 复制文件
echo "复制应用文件..."
cp -r * "$INSTALL_DIR/"

# 更新.desktop文件中的路径
echo "配置桌面文件..."
sed "s|%k|$INSTALL_DIR|g" desktop-timer.desktop > "$DESKTOP_FILE"
chmod +x "$DESKTOP_FILE"

# 确保启动脚本有执行权限
chmod +x "$INSTALL_DIR/desktop-timer.sh"

echo ""
echo "✅ 安装完成！"
echo "✅ Installation completed!"
echo ""
echo "使用方法 / Usage:"
echo "1. 在应用程序菜单中找到'桌面时钟' / Find 'Desktop Timer' in application menu"
echo "2. 或者运行: $INSTALL_DIR/desktop-timer.sh"
echo "3. 或者双击桌面文件: $DESKTOP_FILE"
echo ""
echo "卸载方法 / Uninstall:"
echo "rm -rf '$INSTALL_DIR'"
echo "rm '$DESKTOP_FILE'"
echo "" 